function checkRegist() {
    // DOM document
    var unameText = $("unameText");
    var uname = unameText.value;

    var unameSpan = $("unameSpan");


    //BOM方式获取 Browser
    //var uname = document.forms[0].uname;
    //用户名不为空,用户名应为6~16位数组和字母组成
    if (null != uname) {
        var unameReg = new RegExp("\\w{6,16}");
        if (unameReg.test(uname)) {
            unameSpan.style.visibility = "hidden";
        } else {
            unameSpan.style.visibility = "visible";
            return false;
        }
    } else {
        unameSpan.style.visibility = "visible";
        return false;
    }

    var pwdText = $("pwdText");
    var pwd = pwdText.value;

    var pwdSpan = $("pwdSpan");
    //密码不为空,密码应为：密码的长度至少为8位
    if (null != pwd) {
        var pwdReg = new RegExp(".{8,}");
        if (pwdReg.test(pwd)) {
            pwdSpan.style.visibility = "hidden";
        } else {
            pwdSpan.style.visibility = "visible";
            return false;
        }
    } else {
        pwdSpan.style.visibility = "visible";
        return false;
    }


    var confirmPwdText = $("confirmPwdText");
    var confirmPwd = confirmPwdText.value;

    var confirmPwdSpan = $("confirmPwdSpan");
    //确认密码不为空,两次密码输入是否一致
    if (null != confirmPwd) {
        if (confirmPwd == pwd) {
            confirmPwdSpan.style.visibility = "hidden";
        } else {
            confirmPwdSpan.style.visibility = "visible";
            return false;
        }
    } else {
        confirmPwdSpan.style.visibility = "visible";
        return false;
    }


    var emailText = $("emailText");
    var email = emailText.value;

    var emailSpan = $("emailSpan");
    //用户邮箱
    if (null != email) {
        var emailReg = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(.[a-zA-Z0-9_-]+)+$/;
        if (emailReg.test(email)) {
            emailSpan.style.visibility = "hidden";
        } else {
            emailSpan.style.visibility = "visible";
            return false;
        }
    } else {
        emailSpan.style.visibility = "visible";
        return false;
    }


    var kaptchaText = $("kaptchaText");
    var kaptcha = kaptchaText.value;

    var kaptchaSpan = $("kaptchaSpan");

    // var kaptchaTrueText = $("kaptchaTrueText");
    // var kaptchaTrue = kaptchaTrueText.value;

    // 验证码
    if (null != kaptcha) {
        if (kaptcha.length == 5) {
            kaptchaSpan.style.visibility = "hidden";
        } else {
            kaptchaSpan.style.visibility = "visible";
            return false;
        }
    } else {
        kaptchaSpan.style.visibility = "visible";
        return false;
    }


    return true;
}

function $(id) {
    return document.getElementById(id);
}

var xmlHttpRequest;

// 如果需要发异步请求，我们需要一个关键的对象XMLHttpRequest
function createXMLHttpRequest() {
    // 符合DOM2标准的浏览器创建方式
    if (window.XMLHttpRequest) {
        xmlHttpRequest = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try {
            xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP")
        } catch (e) {
            xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP")
        }
    }
}

function ckUname(uname) {
    createXMLHttpRequest();
    var url = "user.do?operate=ckUname&uname=" + uname;
    xmlHttpRequest.open("GET", url, true);
    // 设置回调函数
    xmlHttpRequest.onreadystatechange = ckUnameCB;
    // 发送请求
    xmlHttpRequest.send();
}

function ckUnameCB() {
    if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
        // 表示服务器端响应给我的文本内容
        //alert(xmlHttpRequest.responseText);
        var responseText = xmlHttpRequest.responseText;
        // {'uname':'1'}
        //var result = eval(responseText);
        //alert(responseText);
        if (responseText == "{'uname':'1'}") {
            alert("用户名已经被注册");
        } else {
            alert("用户名可以被注册");
        }
    }
}